package logic.common.game.endConditions;

import logic.common.game.Game;
import logic.common.team.Team;
import logic.nodes.DestructionEvent;
import logic.nodes.DestructionListener;

public class MotherShipCondition extends MatchEndCondition {
	
	public MotherShipCondition(Game game) {
		super(game);
		
		addMotherShipListener(game.getTeamA());
		addMotherShipListener(game.getTeamB());
	}
	
	protected void addMotherShipListener(final Team team) {
		team.getMotherShip().addDestructionListener(new DestructionListener() {
			@Override
			public void destroyed(DestructionEvent event) {
				endGame(team);
			}
		});
	}
}